<%@page import="com.kaishengit.dao.CarItem"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ include file="top.jsp" %>
  
<html>
  <head>
    <title>My JSP 'order.jsp' starting page</title>
  </head>
  <body>
  	<div class="container" style="padding-top:40px">
	 	<form action="prod.jspx?m=order" method="post" class="form-horizontal">
	 		<fieldset>
		 		<legend style="color:red">收货信息</legend>
		 		<div class="control-group">
		 			<label class="control-label">姓名</label>
	 				<div class="controls">
						<input style="height:30px" type="text" name="name" >		 		
		 			</div>
		 		</div>
		 		
		 		<div class="control-group">
		 			<label class="control-label">地址</label>
		 			<div class="controls">
		 				<input style="height:30px" type="text" name="address" >
		 			</div>
		 		</div>
		 		
		 		<div class="control-group">
		 			<label class="control-label">电话</label>
		 			<div class="controls">
		 				<input style="height:30px" type="text" name="tel" >
		 			</div>
		 		</div>
		 		
		 		<div class="form-actions span4">
		 			<button class="btn btn-success">提交订单</button>
		 		</div>
	 		</fieldset>
	 	</form>
	 </div>
	 <%
		float total = 0f;
		List<CarItem> list = (List<CarItem>)session.getAttribute("shopCar");
		if(list == null || list.isEmpty()) {
			response.sendRedirect("home.jsp");
			return; 
		}else{
	 %>
		<div class="container">
			<div style="float:right">
	          		<a href="prod.jspx" style="font-size:14px">←返回主页</a>
	        </div>
			<div>
				<table class="table table-striped" style="margin-top:20px" >
			<thead>
				<tr>
			 		<th>商品名称</th>
			 		<th>商品单价</th>
			 		<th>商品数量</th>
			 		<th>商品总价</th>
		 		</tr>	
			</thead>
			<%
		 	for(CarItem item : list) {
		 		total += item.getTotal();
		    %>
				
			<tr>
			  	<td><%=item.getProd().getProdname() %></td>
			  	<td>￥<%=item.getProd().getPrice() %></td>
			  	<td>
			  		<input type="text" name="num" style="width:40px;height:20px" value="<%=item.getNum()%>">
			  	</td>
			  	<td>￥<%=item.getTotal() %></td>
		  </tr>
		  <%} }%>
		</table>
			</div>
		<div style="float:right">
			<h3>总共需要支付￥<%=total%>元</h3><hr/>
		</div>
	</div>	 
  </body>
</html>
